<!DOCTYPE html>
<!--
  Copyright 2011 Google Inc. All Rights Reserved.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<html>
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="UTF-8">
	
	<style>
		#map-canvas {
			width: 100%;
			height: 800px;
		}
	</style>

    <title>Fusion Tables Layer Example: Multiple Layers per Map</title>

    <link href="/apis/fusiontables/docs/samples/style/default.css"
        rel="stylesheet" type="text/css">
    <script type="text/javascript"
        src="http://maps.google.com/maps/api/js?sensor=false"></script>

    <script type="text/javascript">
      function initialize() {
        var map = new google.maps.Map(document.getElementById('map-canvas'), {
          center: new google.maps.LatLng(38.8421, -77.219),
          zoom: 12,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        });

        var infoWindow = new google.maps.InfoWindow();

        // Initialize the Library layer
        var firstLayer = new google.maps.FusionTablesLayer({
          query: {
            select: 'Address',
            from: '1oWXhvE59iXw_dugKltVxHU1lbzDwUdFhAOtmAqs'
          },
          map: map,
          suppressInfoWindows: true,
		  styles: [{
			markerOptions: {
				iconName: "star"
			}
		  }]
        });
        google.maps.event.addListener(firstLayer, 'click', function(e) {
          windowControl(e, infoWindow, map);
        });

        // Initialize the house layer
        var secondLayer = new google.maps.FusionTablesLayer({
          query: {
			select: "col9",
			from: "3762007",
			where: ""
  		  },
          map: map,
          suppressInfoWindows: true
        });
		
		secondLayer.setOptions({
			styleId : 1,
			templateId : 2
		}); 
        google.maps.event.addListener(secondLayer, 'click', function(e) {
          windowControl(e, infoWindow, map);
        });
		
		var metroStations = new google.maps.FusionTablesLayer({
			query: {
				select: "geometry",
				from: '1tdSPDWJj1v4zhXbxCHhbY3Cdxrd5pzpaUIUVGzo'
			},
			map: map,
			suppressInfoWindows: true,
		  /*styles: [{
			markerOptions: {
				iconName: "open_diamond"
			}
		  }]*/
		});
		google.maps.event.addListener(metroStations, 'click', function(e) {
			windowControl(e, infoWindow, map);
		});
      }

      // Open the info window at the clicked location
      function windowControl(e, infoWindow, map) {
        infoWindow.setOptions({
          content: e.infoWindowHtml,
          position: e.latLng,
          pixelOffset: e.pixelOffset
        });
        infoWindow.open(map);
      }

      google.maps.event.addDomListener(window, 'load', initialize);
    </script>
  </head>
  <body>
  <div>Bookmark the below link to get a popup window on any MLS listing, it'll prepopulate fields on redfin and mrislistings</div>
<!--  <script>
  (function() {
	var po = document.createElement('script');
	po.type = 'text/javascript';
	po.async = true;
	po.src = 'file://C:/Users/matt/workspace/SmallProjects/MLSBookmarklet/mls-popup-full.js';
	var s = document.getElementsByTagName('script')[0];
	s.parentNode.insertBefore(po, s);
  })()
  </script>-->
  <a href="javascript:(function() {
	var po = document.createElement('script');
	po.type = 'text/javascript';
	po.async = true;
	po.src = 'http://matts-small-projects.googlecode.com/hg/MLSBookmarklet/mls-popup-min.js';
	var s = document.getElementsByTagName('script')[0];
	s.parentNode.insertBefore(po, s);
  })()">Add Listing</a>
    <div id="map-canvas"></div>
  </body>
</html>